﻿Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Xml.Linq
Imports GenDotNet.TemplateSupport
Imports GenDotNet.Task.Common
Imports GenDotNet.StoredProcModel
Imports GenDotNet.TemplateSupport.Strings
Imports <xmlns:orm="http://kadgen.com/KADORM.xsd">
Imports <xmlns="http://kadgen.com/tempCode.xsd">
Imports GenDotNet.TemplateSupport.SqlServer

Public Class SelectSpTemplate
   Inherits SqlServerBase

#Region "Overriding methods"

   Public Overrides ReadOnly Property Id() As System.Guid
      Get
         Return New Guid("{52E5AA74-18CA-4bad-A48B-BCC172A13940}")
      End Get
   End Property

   Protected Overrides ReadOnly Property StoredProcedureName() As String
      Get
         Return "Select_" & EntityData.Name
      End Get
   End Property

#End Region

   Protected Overrides Function GenerateContents() _
            As String
      If Not EntityData.DoGenerateRetrieve Then
         Return Nothing
      End If
      Return _
<code>
   <%= OutputRetrieve(True, EntityData.Recordset) %>
   <%= From child In EntityData.Children _
      Let childEntity = child.ChildEntity _
      Select OutputRetrieve(False, child.ChildJoin, childEntity.Recordset) %>
</code>.Value

   End Function

End Class
